package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.WorkflowProcessService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.WorkflowProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @ Description:
 * @ Author: DuYaTao
 * @ Date: 2025/9/19 - 14:08
 */

@RestController
@RequestMapping("/workflowProcess")
public class WorkflowProcessController {

    @Autowired
    private WorkflowProcessService workflowProcessService;

    @GetMapping("/page")
    public Result<PageInfo<WorkflowProcess>> page(WorkflowProcess workflowProcess, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size){
        return workflowProcessService.getList(workflowProcess, page, size);
    }

    @PostMapping("/add")
    public Result<WorkflowProcess> add(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.addWorkflowProcess(workflowProcess);
    }

    @GetMapping("/{id}")
    public Result<WorkflowProcess> selectById(@PathVariable Long id){
        return workflowProcessService.selectById(id);
    }

    @PutMapping("/update")
    public Result<WorkflowProcess> update(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.updateWorkflowProcess(workflowProcess);
    }

    @DeleteMapping("/delete/{id}")
    public Result<WorkflowProcess> deleteById(@PathVariable Long id){
        return workflowProcessService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result<WorkflowProcess> deleteBatchByIds( Long[] id){
        return workflowProcessService.deleteBatchByIds(id);
    }
}
